/*
 * fifo.h
 *
 *  Created on: Jul 20, 2022
 *      Author: fanlida
 */
 
#ifndef	__FIFO_H__
#define	__FIFO_H__

//#include "printf.h"

#define 	TURE	1
#define 	FALSE	0

//定义队列结构体
typedef struct
{
	unsigned char	*list;		//缓冲区内存指针
	unsigned int	size;		//缓冲区最大长度
	unsigned int	pwrite;		//写指针
	unsigned int	pread;		//读指针
}fifo_t;

/*************************************************************************************************************************
1. fifo_init		初始化 FIFO  f队列结构体，queuelist缓冲区基地址，size缓冲区大小
2. fifo_len			获得 FIFO 里的数据的长度
3. fifo_size		获得 FIFO 的容量（即 FIFO 的缓冲区的大小）
4. fifo_is_empty	判断 FIFO 是否为空
5. fifo_is_full		判断 FIFO 是否为满
6. fifo_put			将数据写入 FIFO
7. fifo_get			从 FIFO 读出数据
*************************************************************************************************************************/	
unsigned char fifo_init(fifo_t *f, unsigned char *queuelist, unsigned int size);
unsigned int fifo_len(const fifo_t *f);
unsigned int fifo_size(const fifo_t *f);
unsigned char fifo_is_empty(const fifo_t *f);
unsigned char fifo_is_full(const fifo_t *f);
unsigned int fifo_put(fifo_t *f, unsigned char *buf, unsigned int len);
unsigned int fifo_get(fifo_t *f, unsigned char *buf, unsigned int len);

#endif

